/*
 * @(#)BuyServiceImplBySolr.java 2012-01-04
 *
 * Copyright 2011 北龙中网（北京）科技有限责任公司. All rights reserved.
 */
package cn.shangjia.shop.service.v2.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import cn.shangjia.common.dao.support.Page;
import cn.shangjia.common.domain.BuyOnline;
import cn.shangjia.common.util.StringUtils;
import cn.shangjia.search.common.bean.SolrBuyInfo;
import cn.shangjia.shop.exception.NotFoundException;
import cn.shangjia.shop.service.BuyService;
import cn.shangjia.shop.service.v2.AbstractSolrService;

/**
 * 基于solr的实现方式
 *
 * @author <a href="mailto:jinzhongze@knet.cn">jinzhongze</a>
 * @version 1.0, 2012-01-04 16:09:21
 * @since 1.0
 */
@Service
public class BuyServiceImpl4Solr extends AbstractSolrService<SolrBuyInfo, BuyOnline> implements BuyService{
	
	/*
	 * (non-Javadoc)
	 * @see cn.shangjia.shop.service.v2.AbstractSolrService#getSolrClientName()
	 * 要拿的solrClient的名字 .  -- 对应配置文件.
	 */
	@Override
	protected String getSolrClientName() {
		return "buySolrClient";
	}
	
	/*
	 * (non-Javadoc)
	 * @see cn.shangjia.shop.service.impl.BuyServiceImpl#findBuyPage(java.lang.String, java.lang.String, int, int)
	 * 重写 列表获取部分, 默认采用 按时间 倒叙的方式 . 
	 */
	@Override
	public Page<BuyOnline> findBuyPage(String userId, String dir, int pageNo, int pageSize) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("userId", userId);
		params.put("dir", dir);
		return getPageObject(params, pageNo, pageSize);
	}

	/*
	 * (non-Javadoc)
	 * @see cn.shangjia.shop.service.BuyService#getBuyById(java.lang.String)
	 * 继续 使用缓存
	 */
	@Override
	public BuyOnline getBuyById(String id) {
		if (StringUtils.isEmpty(id))
			throw new NotFoundException();
		return getObject(id);
	}


}
